package com.taoz.rpc.core.server;

import io.vertx.core.Vertx;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class VertxHttpServer implements Server {
    @Override
    public void start(int port) {
        Vertx vertx = Vertx.vertx();
        io.vertx.core.http.HttpServer server = vertx.createHttpServer();

        server.requestHandler(new VertxHttpRequestHandler());

        server.listen(port, result -> {
            if (result.succeeded()) {
                log.info("Server is now listening at port: " + port);
            } else {
                log.info("Fail to start server: " + result.cause());
            }
        });
    }
}
